#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s[100010],str;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	cin >> str;
	sort(s, s + n);
	int sz = str.size();
	for (int i = 0; i < n; i++)
	{
		if (s[i].substr(0, sz) == str)
			cout << s[i] << endl;
	}
	return 0;
}